
export class Identify {

  // 根据身份证号获得性别、生日
  getInfo(psidno) {
    var sexno, sex, birthdayno, birthdaytemp
    if (psidno.length == 18) {
      sexno = psidno.substring(16, 17)

      birthdayno = psidno.substring(6, 14)

    } else if (psidno.length == 15) {
      sexno = psidno.substring(14, 15)

      birthdaytemp = psidno.substring(6, 12)
      birthdayno = "19" + birthdaytemp

    } else {
      //alert("错误的身份证号码，请核对！")
      return false
    }
    const tempid = sexno % 2;
    if (tempid == 0) {
      sex = 2 // 女
    } else {
      sex = 1 // 男
    }

    const birthday = birthdayno.substring(0, 4) + "-" + birthdayno.substring(4, 6) + "-" + birthdayno.substring(6, 8)

    return {
      sex, birthday
    }
  }
}
